<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head></h:head>
<body>

	<h:form id="srchForm">

		<p:selectOneRadio id="options" value="#{researchBean.selectedProd}"
			style="border: none">
			<f:selectItem itemLabel="Flight" itemValue="flight" />
			<f:selectItem itemLabel="Hotel" itemValue="hotel" />
			<f:selectItem itemLabel="Excursion" itemValue="excursion" />
			<f:selectItem itemLabel="Pack" itemValue="pack" />
			<p:ajax update="srchForm" />
		</p:selectOneRadio>

		<p:outputPanel id="researchFormVolo"
			rendered="#{researchBean.selectedProd == 'flight' }">

			<h5>When?</h5>
			<h:outputText value="departure date: " />
			<p:calendar value="#{researchBean.volo.dataInizio}"
				pattern="dd/MM/yyyy" mindate="#{researchBean.today}">
				<p:ajax event="dateSelect" update="researchFormVolo" />
			</p:calendar>

			<h:outputText value="return date: " />
			<p:calendar value="#{researchBean.volo.dataFine}"
				pattern="dd/MM/yyyy" mindate="#{researchBean.volo.dataInizio}" />

			<h5>Where?</h5>
			<h:outputText value="departure city: " />
			<p:inputText id="departureCity"
				value="#{researchBean.volo.citta_partenza}" />

			<h:outputText value="arrival city: " />
			<p:inputText id="arrivalCity"
				value="#{researchBean.volo.citta_arrivo}" />

			<h5>Who?</h5>
			<h:outputText value="guests: " />
			<p:spinner id="minmax" value="#{researchBean.guests}" min="1"
				max="10"
				style="padding: 0px 20px 0px 0px; height: 36px; width: 100%" />


			<p:outputPanel id="mostraVoli">

				<h:panelGrid id="displayVoli" columns="2" cellpadding="5"
					rendered="#{researchBean.renderVoloList}">

					<p:dataTable var="voloDTO" value="#{researchBean.voloList}"
						paginator="true" rows="10" rowKey="#{voloDTO.id}"
						selection="#{researchBean.volo}" selectionMode="single">

						<p:ajax event="rowSelect" listener="#{researchBean.buySelected}" />

						<p:column headerText="company">
							<h:outputText value="#{voloDTO.compagnia}" />
						</p:column>
						<p:column headerText="departure date">
							<h:outputText value="#{voloDTO.dataInizio}" />
						</p:column>
						<p:column headerText="arrival date">
							<h:outputText value="#{voloDTO.dataFine}" />
						</p:column>
						<p:column headerText="departure city">
							<h:outputText value="#{voloDTO.citta_partenza}" />
						</p:column>
						<p:column headerText="arrival city">
							<h:outputText value="#{voloDTO.citta_arrivo}" />
						</p:column>

						<p:column style="width:4%">
							<p:commandButton id="selectButton" icon="ui-icon-star"
								title="add to gift list" action="#{researchBean.addToGF()}">
								<f:setPropertyActionListener value="#{voloDTO}"
									target="#{researchBean.volo}" />
							</p:commandButton>
						</p:column>
					</p:dataTable>

				</h:panelGrid>

				<p:commandButton value="Search" update="mostraVoli"
					action="#{researchBean.searchVolo()}" style="margin-top: 20px" />

			</p:outputPanel>



		</p:outputPanel>

		<p:outputPanel id="researchFormHotel"
			rendered="#{researchBean.selectedProd == 'hotel' }">

			<h5>When?</h5>
			<h:outputText value="starting date: " />
			<p:calendar value="#{researchBean.hotel.dataInizio}"
				pattern="dd/MM/yyyy" mindate="#{researchBean.today}">
				<p:ajax event="dateSelect" update="researchFormHotel" />
			</p:calendar>

			<h:outputText value="ending date: " />
			<p:calendar value="#{researchBean.hotel.dataFine}"
				pattern="dd/MM/yyyy" mindate="#{researchBean.hotel.dataInizio}" />

			<h5>Where?</h5>
			<h:outputText value="city: " />
			<p:inputText value="#{researchBean.hotel.citta}" />

			<h5>Who?</h5>
			<h:outputText value="guests: " />
			<p:spinner value="#{researchBean.guests}" min="1" max="10"
				style="padding: 0px 20px 0px 0px; height: 36px; width: 100%" />


			<p:outputPanel id="mostraHotels">

				<h:panelGrid id="displayHotels" columns="2" cellpadding="5"
					rendered="#{researchBean.renderHotelList}">

					<p:dataTable var="hotelDTO" value="#{researchBean.hotelList}"
						paginator="true" rows="10" rowKey="#{hotelDTO.id}"
						selection="#{researchBean.hotel}" selectionMode="single">

						<p:ajax event="rowSelect" listener="#{researchBean.buySelected}" />

						<p:column headerText="hotel">
							<h:outputText value="#{hotelDTO.nome}" />
						</p:column>


						<p:column headerText="departure date">
							<h:outputText value="#{hotelDTO.dataInizio}" />
						</p:column>

						<p:column headerText="arrival date">
							<h:outputText value="#{hotelDTO.dataFine}" />
						</p:column>

						<p:column headerText="city">
							<h:outputText value="#{hotelDTO.citta}" />
						</p:column>

						<p:column style="width:4%">
							<p:commandButton id="selectButton" icon="ui-icon-star"
								title="add to gift list" action="#{researchBean.addToGF()}">
								<f:setPropertyActionListener value="#{hotelDTO}"
									target="#{researchBean.hotel}" />
							</p:commandButton>
						</p:column>
					</p:dataTable>

				</h:panelGrid>
			</p:outputPanel>

			<p:commandButton value="Search" update="mostraHotels"
				action="#{researchBean.searchHotel()}" style="margin-top: 20px" />

		</p:outputPanel>


		<p:outputPanel id="researchFormEscursione"
			rendered="#{researchBean.selectedProd == 'excursion' }">

			<h5>When?</h5>
			<h:outputText value="date: " />
			<p:calendar value="#{researchBean.escursione.dataInizio}"
				pattern="dd/MM/yyyy" mindate="#{researchBean.today}">
				<p:ajax event="dateSelect" update="researchFormEscursione" />
			</p:calendar>

			<h5>Where?</h5>
			<h:outputText value="city: " />
			<p:inputText value="#{researchBean.escursione.citta}" />

			<h5>Who?</h5>
			<h:outputText value="guests: " />
			<p:spinner value="#{researchBean.guests}" min="1" max="10"
				style="padding: 0px 20px 0px 0px; height: 36px; width: 100%" />


			<p:outputPanel id="mostraEscursioni">

				<h:panelGrid id="displayExcursions" columns="2" cellpadding="5"
					rendered="#{researchBean.renderEscursioneList}">

					<p:dataTable var="escursioneDTO"
						value="#{researchBean.escursioneList}" paginator="true" rows="10"
						rowKey="#{escursioneDTO.id}"
						selection="#{researchBean.escursione}" selectionMode="single">

						<p:ajax event="rowSelect" listener="#{researchBean.buySelected}" />


						<p:column headerText="date">
							<h:outputText value="#{escursioneDTO.dataInizio}" />
						</p:column>

						<p:column headerText="city">
							<h:outputText value="#{escursioneDTO.citta}" />
						</p:column>

						<p:column headerText="time">
							<h:outputText value="#{escursioneDTO.oraInizio}" />
						</p:column>

						<p:column style="width:4%">
							<p:commandButton id="selectButton" icon="ui-icon-star"
								title="add to gift list" action="#{researchBean.addToGF()}">
								<f:setPropertyActionListener value="#{escursioneDTO}"
									target="#{researchBean.escursione}" />
							</p:commandButton>
						</p:column>

					</p:dataTable>

				</h:panelGrid>

			</p:outputPanel>

			<p:commandButton value="Search" update="mostraEscursioni"
				action="#{researchBean.searchEscursione()}" style="margin-top: 20px" />

		</p:outputPanel>

		<p:outputPanel id="researchFormPacchetto"
			rendered="#{researchBean.selectedProd == 'pack' }">

			<h5>When?</h5>
			<h:outputText value="departure date: " />
			<p:calendar value="#{researchBean.pacchetto.dataInizio}"
				pattern="dd/MM/yyyy" mindate="#{researchBean.today}">
				<p:ajax event="dateSelect" update="researchFormPacchetto" />
			</p:calendar>

			<h:outputText value="return date: " />
			<p:calendar value="#{researchBean.pacchetto.dataFine}"
				pattern="dd/MM/yyyy" mindate="#{researchBean.pacchetto.dataInizio}" />


			<h5>Who?</h5>
			<h:outputText value="guests: " />
			<p:spinner value="#{researchBean.guests}" min="1" max="10"
				style="padding: 0px 20px 0px 0px; height: 36px; width: 100%" />

			<p:outputPanel id="mostraPacchetti">

				<h:panelGrid id="displayPacchetti" columns="2" cellpadding="5"
					rendered="#{researchBean.renderPacchettoList}">

					<p:dataTable var="pacchettoDTO"
						value="#{researchBean.pacchettoList}" paginator="true" rows="10"
						rowKey="#{pacchettoDTO.id}" selection="#{researchBean.pacchetto}"
						selectionMode="single">

						<p:ajax event="rowSelect" listener="#{researchBean.buySelected}" />

						<p:column headerText="nome">
							<h:outputText value="#{pacchettoDTO.nome}" />
						</p:column>
						<p:column headerText="departure date">
							<h:outputText value="#{pacchettoDTO.dataInizio}" />
						</p:column>
						<p:column headerText="arrival date">
							<h:outputText value="#{pacchettoDTO.dataFine}" />
						</p:column>
						<p:column headerText="description: ">
							<h:outputText value="#{pacchettoDTO.descrizione}" />
						</p:column>

						<p:column style="width:4%">
							<p:commandButton id="selectButton" icon="ui-icon-star"
								title="add to gift list" action="#{researchBean.addToGF()}">
								<f:setPropertyActionListener value="#{pacchettoDTO}"
									target="#{researchBean.pacchetto}" />
							</p:commandButton>
						</p:column>

						<p:column style="width:4%">
							<p:commandButton id="inviteButton" icon="ui-icon-heart"
								title="invite friend" oncomplete="PF('invita').show()">
								<f:setPropertyActionListener value="#{pacchettoDTO}"
									target="#{researchBean.pacchetto}" />
							</p:commandButton>
						</p:column>

					</p:dataTable>

				</h:panelGrid>

				<p:dialog id="dlg" header="Inviting friend" widgetVar="invita"
					resizable="false" width="500" showEffect="fade" hideEffect="fade">
					<p:outputLabel>sending email to friend   </p:outputLabel>
					<p:inputText></p:inputText>
					<p:commandButton value="Invite">
						<f:ajax event="click" onevent="dlg.hide()"></f:ajax>
					</p:commandButton>
				</p:dialog>
			</p:outputPanel>

			<p:commandButton value="Search" update="mostraPacchetti"
				action="#{researchBean.searchPacchetto()}" style="margin-top: 20px" />

		</p:outputPanel>
	</h:form>


</body>
</html>
